package com.sky.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.annotation.AutoFill;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {
    /**
     * 根据菜品id查询菜品关联套餐id
     * @param ids
     * @return
     */
    List<Long> getSetmealIdByDishIds(List<Long> ids);

    /**
     *根据套餐id删除套餐的菜品
     * @param setmealId
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void deleteBySetmealId(Long setmealId);

    /**
     * 批量新增套餐的菜品
     * @param setmealDishes
     */
    @AutoFill(OperationType.INSERT)
    void insetBatch(List<SetmealDish> setmealDishes);

    /**
     * 根据id查询套餐关联的菜品
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getByIdSetmeal(Long id);

    /**
     * 批量删除套餐中的菜品
     * @param ids
     */
    void deleteBySetmealIds(List<Long> ids);
}
